package deliciouse.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import deliciouse.biz.CategoryBiz;
import deliciouse.biz.FoodBiz;
import deliciouse.biz.impl.CategoryBizImpl;
import deliciouse.biz.impl.FoodBizImpl;
import deliciouse.entity.Category;
import deliciouse.entity.Food;
@WebServlet("/juggaddfood")
public class FoodListManegeJuggleServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		int cid = 0;
		if(request.getParameter("cid")!=null&&!request.getParameter("cid").isEmpty()){
			cid=Integer.valueOf(request.getParameter("cid"));
		}
		int id = 0;
		if(request.getParameter("id")!=null && !request.getParameter("id").isEmpty())
			id= Integer.valueOf(request.getParameter("id"));
/*		FoodDao fooddao = new FoodDaoImpl();
		CategoryDao categorydao =new CategoryDaoImpl();
		List<Category> categorylist = categorydao.getAll();
		Food food = fooddao.fetchById(id);*/
		FoodBiz foodbiz = new FoodBizImpl();
		CategoryBiz categorybiz = new CategoryBizImpl();
		List<Category> categorylist =categorybiz.getAll();
		Food food =foodbiz.fetchById(id);
		request.setAttribute("categorylist", categorylist);
		request.setAttribute("cid", cid);
		request.setAttribute("id", id);
		request.setAttribute("food", food);
		request.getRequestDispatcher("admin/foodlistupdate.jsp").forward(request, response);;
	}

}
